#include<bits/stdc++.h>
using namespace std;
int n,m;
double L;
double V;
struct nb{
    double d,v,a;
}a[100005];
double p[100005];
struct op{
    int l,r;
}b[100005];
bool cmp(op o,op p){
    return o.l<p.l;
}
int tot;
double pp=1e-7;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        tot=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            scanf("%lf%lf%lf",&a[i].d,&a[i].v,&a[i].a);
            //a[i].d*=L;
        }
        for(int i=1;i<=m;i++){
            scanf("%lf",&p[i]);
            //p[i]*=L;
        }
        p[m+1]=1e18;
        int ans1=0,ans2=0;
        for(int i=1;i<=n;i++){
            int l=lower_bound(p+1,p+m+2,a[i].d)-p;
            if(l==m+1)continue;
            if(a[i].v<=V&&a[i].a<=0)continue;
            if(a[i].v>V&&a[i].a>=0){
                if(m>=l)ans1++,b[++tot]=op{l,m};
            }
            else if(a[i].v<=V){
                double s=(V*V-a[i].v*a[i].v)/2.0/a[i].a;
                l=upper_bound(p+1,p+m+2,s+a[i].d)-p;
                if(m>=l)ans1++,b[++tot]=op{l,m};
            }
            else if(a[i].v>V){
                double s=(V*V-a[i].v*a[i].v)/2.0/a[i].a;
                int r=lower_bound(p+1,p+m+2,s+a[i].d)-p-1;
                if(r>=l)ans1++,b[++tot]=op{l,r};
            }
        }
        sort(b+1,b+tot+1,cmp);
        int mi=b[1].r;
        for(int i=1;i<=tot;i++){
            if(b[i].l>mi)ans2++,mi=b[i].r;
            mi=min(mi,b[i].r);
        }
        if(tot)ans2++;
        cout<<ans1<<" "<<m-ans2<<"\n";
    }
    return 0;
}
//g++ detect.cpp -o detect -O2